/******************************************************************************
    Filename: main.c

    Copyright 2007 Texas Instruments, Inc.
******************************************************************************/

#include "hal_types.h"
#include "hal_board.h"
#include "hal_mcu.h"
#include "hal_rf.h"
#include "cc2500.h"
#include "msp430x22x4.h"
#include "hal_joystick.h"

//----------------------------------------------------------------------------------
//  void main(void)
//
//----------------------------------------------------------------------------------
volatile unsigned int i;

void main(void)
{	
	// Initialize board
    halBoardInit();

    // Initialize joy stick
    js_vInit();

    // Reset CC2500
    halRfResetChip();

    // Setup CC2500
    halRfSetupChip(&rfSettings, au8PaTable, 8);

    while(1)
    {
    	// Sample buttons of the NES controller
    	js_vSampleButtons();

    	// Set date to send
		halRfWriteFifo((const uint8 *)&tRfTxMsg, 4);

        // Sender: Enable Tx
        halRfStrobe(CC2500_STX);

        if(tRfTxMsg.tNesBotton.nesStart)
        {
        	halDigioSet(&pinLed2);
        }
        else
        {
        	halDigioClear(&pinLed2);
        }

		// Wait for 20ms
        halMcuWaitUs(20000);
    }
}
